//
//  YBMySettingTableViewCell.m
//  ZhongWangYuanApp
//
//  Created by apple on 2019/1/29.
//  Copyright © 2019年 apple. All rights reserved.
//

#import "YBMySettingTableViewCell.h"

@interface YBMySettingTableViewCell ()

@property (nonatomic , strong) UILabel * myTitleLabel;

@property (nonatomic , strong) UILabel * myContentLabel;

@property (nonatomic , strong) UIImageView * headImageView;

@end

@implementation YBMySettingTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initMyCell];
    }
    return self;
}


-(void)initMyCell
{
    [self.contentView addSubview:self.myTitleLabel];
    [self.contentView addSubview:self.myContentLabel];
    [self.contentView addSubview:self.headImageView];
    
    self.myTitleLabel.sd_layout
    .leftSpaceToView(self.contentView, ItemWidth * 30)
    .topSpaceToView(self.contentView, 0)
    .bottomSpaceToView(self.contentView, 0)
    .widthIs([UIScreen zj_screenWith] / 2 - ItemWidth * 30);
    
    self.myContentLabel.sd_layout
    .rightSpaceToView(self.contentView, ItemWidth * 30)
    .topSpaceToView(self.contentView, 0)
    .bottomSpaceToView(self.contentView, 0)
    .widthIs([UIScreen zj_screenWith] / 2 - ItemWidth * 30);
    
    self.headImageView.sd_layout
    .rightSpaceToView(self.contentView, ItemWidth * 30)
    .centerYEqualToView(self.myContentLabel)
    .widthIs(ItemHeight * 80)
    .heightIs(ItemHeight * 80);
    
    self.headImageView.sd_cornerRadius = @(ItemHeight * 40);
    
    UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
    lineView.backgroundColor = [UIColor themeGrayColor];
    [self.contentView addSubview:lineView];
    lineView.sd_layout
    .bottomSpaceToView(self.contentView, 0)
    .leftSpaceToView(self.contentView, ItemWidth * 30)
    .rightSpaceToView(self.contentView, ItemWidth * 30)
    .heightIs(normalBorderWidth);
    
}

-(void)setDataDic:(NSDictionary *)dataDic
{
    _dataDic = dataDic;
    self.myTitleLabel.text = dataDic[@"title"];
    if ([dataDic[@"isHeadImage"] isEqualToString:@"1"]) {
        self.headImageView.hidden = NO;
        self.myContentLabel.hidden = YES;
        [self.headImageView sd_setImageWithURL:CREATEURL(dataDic[@"content"]) placeholderImage:PlaceholderHeaderImage];
    }
    else{
        self.headImageView.hidden = YES;
        self.myContentLabel.hidden = NO;
        self.myContentLabel.text = dataDic[@"content"];
    }
}




-(UILabel *)myTitleLabel
{
    if (!_myTitleLabel) {
        _myTitleLabel = [ToolClass creatLabelWithFrame:CGRectMake(0, 0, 1, 1) font:16 textColor:[UIColor textBlackColor] text:@""];
    }
    return _myTitleLabel;
}


-(UILabel *)myContentLabel
{
    if (!_myContentLabel) {
        _myContentLabel = [ToolClass creatLabelWithFrame:CGRectMake(0, 0, 1, 1) font:15 textColor:[UIColor textBlackColor] text:@""];
        _myContentLabel.textAlignment = NSTextAlignmentRight;
    }
    return _myContentLabel;
}

-(UIImageView *)headImageView
{
    if (!_headImageView) {
        _headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
        _headImageView.hidden = YES;
    }
    return _headImageView;
}



@end
